import { legacy_createStore as createStore, applyMiddleware } from 'redux'

// createSagaMiddleware 创建 saga 中间件的方法
import createSagaMiddleware from 'redux-saga'
import mySaga from './mySaga'

import app from './modules/app'
import pro from './modules/pro'

import { combineReducers } from 'redux-immutable'

// 创建一个中间件
const sagaMiddleware = createSagaMiddleware()

const reducer = combineReducers({
  app,
  pro
})

//applyMiddleware(sagaMiddleware) 应用异步模块
const store = createStore(reducer, applyMiddleware(sagaMiddleware))

// 使 saga 中的异步操作生效
sagaMiddleware.run(mySaga)

export default store
